/**
 * User is the class implementing a user.
 * 
 * Users are needed to process authentication.
 *  
 * @author Eric LEON
 * @version 1.0.0
 */
package models;

import javax.persistence.Entity;

import org.hibernate.annotations.NaturalId;

import play.data.validation.Email;
import play.db.jpa.Model;

/**
 * @author eric
 *
 */
@Entity(name="tdUser")
public class User extends Model {

	@Email
	@NaturalId
	public String email;
	
	public String password;
	
	public String fullname;
	public boolean isAdmin;
	
	public User(String email, String password, String fullname) {
		this.email = email;
		this.password = password;
		this.fullname = fullname;
	}
	
	@Override
	public String toString() {
		return this.fullname;
	}
	
	public static User connect(String email, String password) {
	    return find("byEmailAndPassword", email, password).first();
	}
}